
## Determines whether nginx should become a daemon and default is on.
daemon  on;

## If master_process is off, there will be only one nginx worker running. Only use it for debug propose.
## Default is on.
master_process  on;


## Defines the number of worker processes every of which will be embedded one JVM instance.
## When auto is specified the number of worker processes will be the number of CPU hardware threads
worker_processes  1;

error_log  logs/error.log error;

events {
    ## Defines the number of connections per worker processes.
    ## Note that this number includes all connections (e.g. connections with proxied servers, among others),
    ## not only connections with clients.
    worker_connections  1024;
}


http {

    ## include file mime.types which defines file type to mime type mappings
    include       mime.types;

    ## Default mime type for unknown file type
    default_type  application/octet-stream;

    ## access log, more details can be found from http://nginx.org/en/docs/http/ngx_http_log_module.html#access_log
    ## when do performance tests try to turn off it, viz. use `access_log off;` instead.
    access_log logs/access.log combined;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    ## Enable gzip,  default is off
    #gzip  on;

    ## Defines the path of JVM, when auto is used nginx-clojure will detect this by itself.
    jvm_path "/home/cyh/.jdks/openjdk-22/lib/server/libjvm.so";

    ## Define class path. When '/*' is used after a directory path all jar files and
    ##sub-directories will be used as the jvm classpath
    jvm_classpath "libs/*:jars/*";

    jvm_options "-Dnginx.clojure.logger.level=error";

    jvm_options "--add-opens=java.base/java.lang=ALL-UNNAMED";
    jvm_options "--add-opens=java.base/sun.nio.cs=ALL-UNNAMED";
    jvm_options "--add-opens=java.base/sun.nio.ch=ALL-UNNAMED";


    ### jvm heap memory
    #jvm_options "-Xms1024m";
    #jvm_options "-Xmx1024m";

    ## Threads number for request handler thread pool on jvm, default is 0 which means disable
    ## thread pool mode. Check more details from section 2.4 in http://nginx-clojure.github.io/configuration.html
    jvm_workers 2;

    ## remote debug
    jvm_options "-Xdebug";
    jvm_options "-Xrunjdwp:server=y,transport=dt_socket,address=840#{pno},suspend=n";


    jvm_handler_type 'java';


    jvm_init_handler_name 'top.chenyaohua.nginx.clojure.NginxClojureInitHandler';

    server {
        listen       8080;
        server_name  localhost;

        location /hello {
            content_handler_name 'top.chenyaohua.nginx.clojure.NginxSpringHandlerWrapper';
            content_handler_property 'router_service' 'routerService';
        }

        ## redirect server error pages to the static page /50x.html
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

    }

}
